/**
 * Copyright ©2012-2018 HopeHaiyang Corporation, All Rights Reserved
 * http://www.wuhanhope.com
 */
package hope.platform.data.web;

import hope.platform.data.domain.SiteConnectionInfo;
import hope.platform.data.server.data.header.SiteConnectionInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * class info
 *
 * @author hujia
 *         Create at 2018/7/12 9:00
 */
@RestController
@RequestMapping("/siteConnectionInfo")
public class SiteConnectionInfoController {

    @Autowired
    private SiteConnectionInfoService service;

    @RequestMapping(method = RequestMethod.POST)
    public SiteConnectionInfo addSiteConnectionInfo(@RequestBody SiteConnectionInfo info) {
        return service.addConnectionInfo(info);
    }

    @RequestMapping(method = RequestMethod.PUT)
    public SiteConnectionInfo updateConnectionInfo(@RequestBody SiteConnectionInfo info) {
        return service.updateConnectionInfo(info);
    }

    @RequestMapping(value = "/all", method = RequestMethod.GET)
    public List<SiteConnectionInfo> getAllSiteConnectionInfo() {
        return service.getAll();
    }

    @RequestMapping(value = "/serialNumber/{serialNumber}", method = RequestMethod.GET)
    public SiteConnectionInfo getSiteConnectionInfo(@PathVariable String serialNumber) throws Exception {
        return service.getBySerialNumber(serialNumber);
    }
}
